package com.yuexunit.finance.member.service;

import java.util.List;

import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.Restrictions;

import com.yuexunit.finance.member.entity.SupplierCommissionGradeEntity;
import com.yuexunit.inject.annotation.Implements;
import com.yuexunit.page.PageCriteria;
import com.yuexunit.page.PageList;
import com.yuexunit.persist.PersistUtil;
import com.yuexunit.persist.annotation.Transactional;

/**
*@version 创建时间：2016年9月27日 上午10:10:41
*@author NTBK-021-1006
*类说明
*/

@Implements(SupplierCommissionGradeService.class)
public class SupplierCommissionGradeServiceImpl implements SupplierCommissionGradeService {

	@Override
	@Transactional
	public Long createSupplierCommissionGrade(SupplierCommissionGradeEntity entity) {
		PersistUtil.insert(entity);
		return entity.getCommissionGradeId();
	}

	@Override
	@Transactional
	public void updateSupplierCommissionGrade(SupplierCommissionGradeEntity entity) {
		PersistUtil.update(entity);
	}

	@Override
	@Transactional
	public void deleteSupplierCommissionGrade(Long commissionGradeId) {
		PersistUtil.delete(SupplierCommissionGradeEntity.class, commissionGradeId);
	}

	@Override
	public SupplierCommissionGradeEntity inquireSupplierCommissionGrade(Long commissionGradeId) {
		return PersistUtil.get(SupplierCommissionGradeEntity.class, commissionGradeId);
	}

	@Override
	public PageList<SupplierCommissionGradeEntity> inquireSupplierCommissionGradePageList(PageCriteria page) {
		DetachedCriteria criteria = DetachedCriteria.forClass(SupplierCommissionGradeEntity.class);
		return PersistUtil.get(criteria, page);
	}

	@Override
	public List<SupplierCommissionGradeEntity> inquireSupplierCommissionGradeList() {
		DetachedCriteria criteria = DetachedCriteria.forClass(SupplierCommissionGradeEntity.class);
		return PersistUtil.get(criteria);
	}

	@Override
	public List<SupplierCommissionGradeEntity> inquireSupplierCommissionGradeList(Long commissionId) {
		DetachedCriteria criteria = DetachedCriteria.forClass(SupplierCommissionGradeEntity.class);
		criteria.add(Restrictions.or(Restrictions.eq("commissionId", commissionId), Restrictions.eq("commissionId", 0L)));
		return PersistUtil.get(criteria);
	}
}
